<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="样品包号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v1">
              <a-input v-model="model.v1" placeholder="请输入样品包号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="样品管编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v2">
              <a-input v-model="model.v2" placeholder="请输入样品管编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="采样日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v3">
              <a-input v-model="model.v3" placeholder="请输入采样日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="采样点ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v4">
              <a-input v-model="model.v4" placeholder="请输入采样点ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="核酸采样机构" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v5">
              <a-input v-model="model.v5" placeholder="请输入核酸采样机构"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v6">
              <a-input v-model="model.v6" placeholder="请输入姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v7">
              <a-input v-model="model.v7" placeholder="请输入证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="证件号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v8">
              <a-input v-model="model.v8" placeholder="请输入证件号码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="出生年月" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v9">
              <a-input v-model="model.v9" placeholder="请输入出生年月"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v10">
              <a-input v-model="model.v10" placeholder="请输入性别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联系地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v11">
              <a-input v-model="model.v11" placeholder="请输入联系地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v12">
              <a-input v-model="model.v12" placeholder="请输入联系电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="检测日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v13">
              <a-input v-model="model.v13" placeholder="请输入检测日期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="核酸检测结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v14">
              <a-input v-model="model.v14" placeholder="请输入核酸检测结果"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="核酸检测机构" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v15">
              <a-input v-model="model.v15" placeholder="请输入核酸检测机构"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="核酸检测机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v16">
              <a-input v-model="model.v16" placeholder="请输入核酸检测机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上报日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="v17">
              <a-input v-model="model.v17" placeholder="请输入上报日期"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'YzHsJlForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/yzHsJl/yzHsJl/add",
          edit: "/yzHsJl/yzHsJl/edit",
          queryById: "/yzHsJl/yzHsJl/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
